package cn.doit.scala.day02.map

/**
 * @DATE 2021/12/25/17:04
 * @Author MDK
 * @Version 2021.2.2
 * */
object C01_Map {
  def main(args: Array[String]): Unit = {
    //定义Map集合两种方式
    val mp1 = Map[String, Int](
      ("zss",23),
      ("lss",33),
      "wbb"->24,
      "zg"->28
    )

      //定义map集合方式二
      val mp2 = Map[Int, Int](
        (1,11),
        2->22,
        3->33,
        (4,44)
      )

    //根据键找值
//    val res: Int = mp1.getOrElse("zss2", 0)
      val maybeInt = mp1.get("zss")
    //判断
    if(maybeInt.isDefined){
      val value: Int = maybeInt.get
      println(value)
    }else{
      println("没有这个值")
    }
  }
}
